import {
    SET_USER_INFO,
    DO,
    DOTHIS,
    DODO,
    GET_USER_INFO,
    USER_ACTION,
    UPDATE_DIRECTION
} from './mutation_types'

const state = {
    userInfo: {
        name: 'user-暂无'
    },
    direction: ''
}
const getters = {
    userInfo: state => {
        return state.userInfo
    }
}
const mutations = {
    [SET_USER_INFO](state, data) {
        state.userInfo = data;
        console.log(data);
    },
    [DO](state, data) {
        console.log(data);
    },
    [DOTHIS](state, data) {
        console.log(data);
    },
    [DODO](state, data) {
        console.log(data);
    }
}
const actions = {
    async [GET_USER_INFO](context) {
        let result = await new Promise((resolve) => {
            setTimeout(() => {
                context.commit('setUserInfo', { name: 'Abiel' })
                resolve({ name: 'Abiel' })
            }, 1000)
        })
        return result
    },
    async [USER_ACTION](context, payload) {
        let result = await new Promise((resolve) => {
            setTimeout(() => {
                context.commit('setUserInfo', { name: 'Abiel' })
                resolve({ name: 'Abiel' })
            }, 1000)
        })
        return result
    }
}

export default {
    namespaced: false,
    state,
    mutations,
    getters,
    actions,
    modules: {}
}
